/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telemetria.entity;

import com.telemetria.entity.endereco.Endereco;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author ARGLAS
 */
@Entity
public class Pessoa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String deNome;
    private String deApelido;    
    private String deRG;
    private String deCPF;
    @ManyToOne
    @JoinColumn(name="id_endereco")
    private Endereco endereco = new Endereco();
    
    @OneToMany(mappedBy = "pessoa", targetEntity = Telefone.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<Telefone> telefones = new ArrayList<Telefone>();

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pessoa)) {
            return false;
        }
        Pessoa other = (Pessoa) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Pessoa[ id=" + id + " ]";
    }

    public Endereco getEndereco() {
        return endereco;
    }

    public void setEndereco(Endereco endereco) {
        this.endereco = endereco;
    }

    public String getDeNome() {
        return deNome;
    }

    public void setDeNome(String deNome) {
        this.deNome = deNome;
    }

    public String getDeApelido() {
        return deApelido;
    }

    public void setDeApelido(String deApelido) {
        this.deApelido = deApelido;
    }
    
    public String getDeRG() {
        return deRG;
    }

    public void setDeRG(String deRG) {
        this.deRG = deRG;
    }

    public String getDeCPF() {
        return deCPF;
    }

    public void setDeCPF(String deCPF) {
        this.deCPF = deCPF;
    }

    public List<Telefone> getTelefones() {
        return telefones;
    }

    public void setTelefones(List<Telefone> telefones) {
        this.telefones = telefones;
    }
    
}
